from odoo import models, fields, api, _
from odoo.exceptions import UserError, ValidationError


# 审批流类
class Workflow(models.Model):
    _inherit = 'sb.workflow'

    # 关联质量检测
    quality_check_id = fields.Many2one('quality.check', string="Related Documents", ondelete="cascade")
    workflow_type = fields.Selection(selection_add=[
        ('quality_check', 'Quality Check')
    ], ondelete={'activity': 'cascade'})
    quality_check_form_ref = fields.Char(string="Quality Check Form Ref", compute='_quality_check_form_ref')

    def _quality_check_form_ref(self):
        for rec in self:
            rec.quality_check_form_ref = 'quality_control.quality_check_view_form'

    @api.model_create_multi
    def create(self, values):
        res = super(Workflow, self).create(values)
        return res
